<%inherit file="base.html"/>

<%def name="head()">
<style type="text/css">
    td {
        text-align: left
    }
</style>
<script>
    function deleteTemplate(tpl_id) {
        if (confirm("确认删除吗？")) {
            window.location.href = "/template/delete?tpl_id=" + tpl_id;
        }
    }
</script>
</%def>

<%def name="body()">
<section class="content">
    <div class="box box-primary">
        <div class="box-header">
            <i class="fa fa-archive"></i>
            <h3 class="box-title">模板列表</h3>
        </div>
        <div class="box-body">
            <div class="container">
            % if permit.match(current_user.username,'/template/add'):
            <div class="pull-right bottom10">
                <a href="/template/add" class="btn btn-sm btn-info">添加模板</a>
            </div>
            % endif

            <table class="table table-hover">
                <thead>
                <tr>
                    <th>模板名称</th>
                    <th>模板描述</th>
                </tr>
                </thead>
                <tbody>
                % for item in tpl_list:
                <tr>
                    <td><a href="/template/detail?tpl_id=${item.id}">${item.tpl_name}</a></td>
                    <td>${item.tpl_desc}</td>
                    <td>
                        % if permit.match(current_user.username,'/template/update'):
                        <a class="opt-btn btn-default" href="/template/update?tpl_id=${item.id}">修改</a>
                        % endif
                        % if permit.match(current_user.username,'/template/delete'):
                        <a class="opt-btn btn-default" href="javascript:deleteTemplate('${item.id}')">删除</a>
                        % endif
                    </td>
                </tr>
                % endfor
                </tbody>
            </table>
        </div>
    </div>
        </div>
</section>
</%def>